package top.fangw.tenant.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.fangw.common.core.result.Result;
import top.fangw.tenant.pojo.dto.SysDictTypeDto;
import top.fangw.tenant.pojo.entity.DatabaseInfo;
import top.fangw.tenant.pojo.vo.DictTypeVo;
import top.fangw.tenant.service.ISysDictTypeService;

import java.util.List;

/**
 * <p>
 * 用途：用于存放字典的类型值 前端控制器
 * </p>
 *
 * @author fangw
 * @since 2024-02-23
 */
@RestController
@RequestMapping("/sys-dict-type")
@Tag(name = "系统字典类型管理")
@RequiredArgsConstructor
public class SysDictTypeController {
    private final  ISysDictTypeService sysDictTypeService;

    @Operation(summary = "添加字典类型信息")
    @PostMapping("/addDictType")
    public Result<?> addDictType(@RequestBody SysDictTypeDto dto){
        sysDictTypeService.addDictType(dto);
        return Result.success();
    }

    @Operation(summary = "字典类型列表")
    @GetMapping("/getDictTypeList")
    public Result<?> getDictTypeList(@RequestParam(required = false,value = "name") String name){
        List<DictTypeVo> resList = sysDictTypeService.getDictTypeList(name);
        return Result.success(resList);
    }

    @Operation(summary = "删除字典类型数据")
    @DeleteMapping("/deleteDictType")
    public Result<?> deleteDictType(@RequestParam("id") String id){
        sysDictTypeService.deleteDictType(id);
        return Result.success();
    }

    @Operation(summary = "更新字典类型信息")
    @PutMapping("/updateDictType")
    public Result<?> updateDictType(@RequestBody SysDictTypeDto dto){
        sysDictTypeService.updateDictType(dto);
        return Result.success();
    }


}
